package com.zsrt.java.day20161226.cg.demo01;

import java.util.Scanner;

public class TestCal01 {
 


	public static void main(String[] args) {
		
		cal();				

	}
	/**
	 * 求两个数的加减乘除以及求模的算法
	 * @param int a 
	 * @param int b 
	 * @param String flag
	 * @return cal()
	 */
	public static void  cal(){
		Scanner sc = new Scanner(System.in);
		System.out.println("输入第一个数");
		int a = sc.nextInt();
		System.out.println("输入符号");
		String fuHao = sc.next();
		System.out.println("输入第二个数");
		int b = sc.nextInt();
		sc.close();
		
		while(true){
			switch(fuHao){
			case "+":System.out.println(a+" + "+b+" = "+add(a,b)); break;
			case "-":System.out.println(a+" - "+b+" = "+jianFa(a,b)); break;
			case "*":System.out.println(a+" * "+b+" = "+chengFa(a,b)); break;
			case "/":System.out.println(a+" / "+b+" = "+chuFa(a,b)); break;
			case "%":System.out.println(a+" % "+b+" = "+qiuMo(a,b)); break;
			case "exit": break;
			default:System.out.println("输入有误");break;
			
		}
		}
	} 
	
	
	public static int add(int a,int b){
		int result;
		result = a + b;
		return result;
	}
	public static int jianFa(int a,int b){
		int result;
		result = a - b;
		return result;
	}
	public static int chengFa(int a,int b){
		int result;
		result = a * b;
		return result;
	}
	public static int chuFa(int a,int b){
		int result;
		result = a / b;
		return result;
	}
	public static int qiuMo(int a,int b){
		int result;
		result = a % b;
		return result;
	}
}

